<template>
<div class="cashback views-container">
    <div class="wlm-table">
        <div class="wlm-table-hearder-btn">
            <router-link tag="span" to="/application/cashbackAdd">
                <el-button size="small" type="primary">添加活动</el-button>
            </router-link>
        </div>
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.userTable.files" size="small" label-width="85px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="活动名称：">
                        <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.userTable.files.name" placeholder="请输入活动名称" style="width:160px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <el-tabs v-model="tableFormatData.userTable.files.type" type="card" @tab-click="filesSerch">
                <el-tab-pane label="支付立减" name="10"></el-tab-pane>
                <el-tab-pane label="支付返现" name="20"></el-tab-pane>
            </el-tabs>
            <el-table :ref="tableFormatData.userTable.key"  :data="tableFormatData.userTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <!-- <el-table-column type="selection" width="55">
                </el-table-column> -->
                <el-table-column prop="date" label="活动名称"  min-width="60">
                    <template slot-scope="scope">
                        <span>{{scope.row.name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="活动时间"  min-width="70">
                    <template slot-scope="scope">
                        <p style="white-space: nowrap;">{{scope.row.time[0] | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                        <p style="white-space: nowrap;">{{scope.row.time[1] | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</p>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="活动状态"  min-width="45">
                    <template slot-scope="scope">
                        <span v-if="scope.row.status==1">未开始</span>
                        <span v-if="scope.row.status==2">进行中 </span>
                        <span v-if="scope.row.status==3">已结束</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="总实付金额"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.pay_money}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" :label="tableFormatData.userTable.files.type=='10'?'订单优惠标记':'总返现金额'"   min-width="45">
                    <template slot-scope="scope">
                        <span v-if="tableFormatData.userTable.files.type=='10'" class="pointer" @click="handleClipboard(scope.row.random_string,$event)">{{scope.row.random_string}}</span>
                        <span v-if="tableFormatData.userTable.files.type=='20'">{{scope.row.return_money}}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="name" label="订单优惠标记" v-if="tableFormatData.userTable.files.type=='10'"  min-width="45">
                    <template slot-scope="scope">
                        <span class="pointer" @click="handleClipboard(scope.row.random_string,$event)">{{scope.row.random_string}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="总返现金额" v-if="tableFormatData.userTable.files.type=='20'"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.return_money}}</span>
                    </template>
                </el-table-column> -->
                <el-table-column prop="name" label="参与人数"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.join_num}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="付款订单数"  min-width="45">
                    <template slot-scope="scope">
                        <span>{{scope.row.order_num}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <router-link v-if="scope.row.type==20" class="wlm-text" tag="span" :to="{path:'/application/cashbackInfo', query :{ id:scope.row.id}}">
                                <el-button type="text">返现记录</el-button>
                            </router-link>
                            <div v-if="scope.row.type==20" class="btn-line"></div>
                            <router-link class="wlm-text" tag="span" :to="{path:'/application/cashbackAdd', query :{ id:scope.row.id}}">
                                <el-button type="text">编辑</el-button>
                            </router-link>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-e flex-align-c">
                <!-- <el-row class="pagination-btns">
                    <el-checkbox class="check-all" true-label="1" false-label="0" v-model="tableFormatData.userTable.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row> -->
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.userTable.pagination.page" :page-sizes="tableFormatData.userTable.pagination.pagesizes" :page-size.sync="tableFormatData.userTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.userTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  getCashBackList,
  delCashBackData
} from '@/api/application'
import mixins from '@/mixins/mixins'
import clipboard from '@/utils/clipboard'
export default {
  mixins: [mixins.getters('Table')],
  name: 'Cashback',
  components: {
  },
  data() {
    return {
      blogTitle: '',
      tableFormatData: {
        current: 'userTable',
        userTable: {
          key: 'userTable',
          api: {
            getList: getCashBackList,
            delList: delCashBackData
            //   msgConfig: {
            //     del: {
            //       type: 'warning',
            //       msg: '此操作会删除用户的所有数据，名下所有平台内如有正在交易的订单、金额，删除后所产生的纠纷由服务商自身承担 如要删除请慎重操作！！'
            //     }
            //   }
          },
          tableData: [],
          files: {
            type: '10',
            name: '',
            ids: [],
            checkall: '0',
            Recycle: '1'
          },
          //   change: {
          //     restore: {
          //       name: '恢复',
          //       key: 'restore',
          //       api: userRestore
          //     }
          //   },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {
    handleClipboard(text, event) {
      clipboard(text, event)
    }
  }
}
</script>
